home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-09 | 3.8 KB | 100 lines | [TEXT/R*ch] |
- // ===========================================================================
- // File: CTargetable.cp
- // Version: 1.0 - Feb 1, 1996
- // Author: Mike Shields (mshields@inconnect.com)
- //
- // Copyright ©1996 Mike Shields. All rights reserved.
- // I hereby grant users of CTargetable permission to use it (or any modified
- // version of it) in applications (or any other type of Macintosh software
- // like extensions -- freeware, shareware, commercial, or other) for free,
- // subject to the terms that:
- //
- // (1) This agreement is non-exclusive.
- //
- // (2) I, Mike Shields, retain the copyright to the original source code.
- //
- // These two items are the only required conditions for use. However, I do have
- // an additional request. Note, however, that this is only a request, and
- // that it is not a required condition for use of this code.
- //
- // (1) That I be given credit for CTargetable code in the copyrights or
- // acknowledgements section of your manual or other appropriate documentation.
- //
- //
- // I would like to repeat that this last item is only a request. You are prefectly
- // free to choose not to do any or all of them.
- //
- // This source code is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- // ===========================================================================
- // CTargetable.h <- double-click + Command-D to see class declaration
- //
- // Mixin class which allows the new sub class to have a "target border"
- // shown around it when the object is the target.
-
- #include "CTargetable.h"
- #include "CTargeterBorder.h"
-
- #include <LCommander.h>
-
- #pragma mark === Construction & Destruction ===
-
- //----------------------------------------------------------------------------------------
- // CTargetable::CTargetable
- //----------------------------------------------------------------------------------------
- // default constructor
- CTargetable::CTargetable()
- : mBorder(nil)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CTargetable::~CTargetable
- //----------------------------------------------------------------------------------------
- // destructor
- CTargetable::~CTargetable()
- {
- }
-
- #pragma mark === Targeting Information ===
- //----------------------------------------------------------------------------------------
- // CTargetable::IsTarget
- //----------------------------------------------------------------------------------------
- // return whether or not the corrent object is the target.
- Boolean CTargetable::IsTargeted(void)
- {
- return (LCommander::GetTarget() == dynamic_cast<LCommander*>(this));
- }
-
- #pragma mark === TargeterBox Management ===
- //----------------------------------------------------------------------------------------
- // CTargetable::SetTargeterBox
- //----------------------------------------------------------------------------------------
- // record the address of the TargeterBox object we're associated with
- void CTargetable::SetTargeterBox(CTargeterBorder* inBorder)
- {
- SignalIf_(inBorder == nil);
- mBorder = inBorder;
- };
-
- //----------------------------------------------------------------------------------------
- // CTargetable::ShowFocus
- //----------------------------------------------------------------------------------------
- // Inform the TargeterBox that it needs to show we're the target
- void CTargetable::ShowFocus(void)
- {
- if ( mBorder )
- mBorder->ShowFocus();
- }
-
- //----------------------------------------------------------------------------------------
- // CTargetable::HideFocus
- //----------------------------------------------------------------------------------------
- // Inform the TargeterBox that it no longer needs to show we're the target
- void CTargetable::HideFocus(void)
- {
- if ( mBorder )
- mBorder->HideFocus();
- }
-